<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回该 id 十六进制的表示形式</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongoid.set-state.html">MongoId::__set_state</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.mongocode.html">MongoCode</a></div>
 <div class="up"><a href="class.mongoid.html">MongoId</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongoid.tostring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoId::__toString</h1>
  <p class="verinfo">(PECL mongo &gt;= 0.8.0)</p><p class="refpurpose"><span class="refname">MongoId::__toString</span> &mdash; <span class="dc-title">返回该 id 十六进制的表示形式</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongoid.tostring-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><strong>MongoId::__toString</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongoid.tostring-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongoid.tostring-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   该 id。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongoid.tostring-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1461">
   <p><strong>Example #1 <span class="function"><strong>MongoId::__toString()</strong></span> 例子</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$collection&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectDB</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"bar"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(&nbsp;</span><span style="color: #DD0000">"x"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"y"&nbsp;</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(&nbsp;</span><span style="color: #DD0000">"x"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"y"&nbsp;</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$r1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">next</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$r2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">next</span><span style="color: #007700">();<br /><br />echo&nbsp;</span><span style="color: #0000BB">$r1</span><span style="color: #007700">[</span><span style="color: #DD0000">"_id"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$r2</span><span style="color: #007700">[</span><span style="color: #DD0000">"_id"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
49a7011a05c677b9a916612a
49a702d5450046d3d515d10d
</pre></div>
   </div>
  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongoid.set-state.html">MongoId::__set_state</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.mongocode.html">MongoCode</a></div>
 <div class="up"><a href="class.mongoid.html">MongoId</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
